﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Cm.Web.Models.Demo;
namespace Cm.Web.Controllers
{
    public class AjaxDemoController : Controller
    {
        //
        // GET: /AjaxDemo/

        public ActionResult Index()
        {
            
            return View();
        }
        [HttpPost]
        public ActionResult Index2(Entity entity)
        {
            if (ModelState.IsValid)
            {
                try
                {

                }
                catch (ValidateException ipex)
                {
                    return Json("验证数据失败!" + ipex.Message, JsonRequestBehavior.AllowGet);
                }
                catch (Exception)
                {

                    throw;
                }

                return Json("保存成功!", JsonRequestBehavior.AllowGet);
            }

            return Json("保存失败!", JsonRequestBehavior.AllowGet);
        }
        
        public ActionResult PreLoadData()
        {
            return View();
        }

        public ActionResult LoadHtml()
        {
            return View();
        }
        
    }

    public class ValidateException : Exception
    {

    }
}
